-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create EscapedFrameIntervalsFinder and ComplexStackVariableTransformer #1157
Conversation
`EscapedFrameIntervalsFinder` finds intervals in the `[[-12, -4], (struct ""str"" 0008 (0 int32 dw0000) (4 real32 r0004))]` form. Then `ComplexStackVariableTransformer` rewrites expressions like `fp - <offset>` if offset is inside of one of the intervals collected by `EscapedFrameIntervalsFinder`. Current implementation works only if user or environment procedure signature is defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions regarding the output. Code looks fine.
@@ -7,7 +7,7 @@ | |||
// 10001000: Register (ptr32 Eq_n) sum_wrapper(Stack (ptr32 Eq_n) ptrArg04, Stack (ptr32 Eq_n) ptrArg08) | |||
PyObject * sum_wrapper(PyObject * ptrArg04, PyObject * ptrArg08) | |||
{ | |||
PyObject * eax_n = PyArg_ParseTuple(ptrArg08, "ii:sum", fp - 0x04, fp - 0x08); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed earlier, the declarations of the two new variables can be done in a future commit.
QueryPerformanceCounter(fp - 0x14); | ||
ui32 esi_n = esi_n ^ (dwLoc10 ^ dwLoc14); | ||
QueryPerformanceCounter(&tLoc14); | ||
ui32 esi_n = esi_n ^ (tLoc14.dw0004 ^ tLoc14); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened here? tLoc14
seems to have sub-structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of tLoc14
is LARGE_INTEGER
union.
typedef union _LARGE_INTEGER {
struct {
DWORD LowPart;
LONG HighPart;
} DUMMYSTRUCTNAME;
struct {
DWORD LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} LARGE_INTEGER;
The result should be
ui32 esi_n = esi_n ^ (tLoc14.HighPart ^ tLoc14.LowPart);
It looks like later phase (TypeAnalysis
/ComplexExpressionRewiter
) can't transform correctly accesses to such unions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make an issue to track this then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1159
There are two phases.
EscapedFrameIntervalsFinder
finds intervals in the[[-12, -4], (struct ""str"" 0008 (0 int32 dw0000) (4 real32 r0004))]
form. Then
ComplexStackVariableTransformer
rewrites expressions likefp - <offset>
if offset is inside of one of the intervals collected byEscapedFrameIntervalsFinder
.Current implementation works only if user or environment procedure
signature is defined.